<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('用户钱包列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <input type="hidden"  name="customerId" th:value="${customerId}">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>押金交易号：</label>
                                <input type="text" name="depositTranNo"/>
                            </li>
                            <li>
                                <label>余额交易号：</label>
                                <input type="text" name="balanceTranNo"/>
                            </li>
                            <li>
                                <label>启用状态：</label>
                                <select name="status" th:with="type=${@dict.getType('enableStatus')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="biz:wallet:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="biz:wallet:export">
                    <i class="fa fa-download"></i> 导出
                </a>
                <a id="closeId" class="btn btn-warning" onclick="closeItem()">
                    <i class="fa fa-reply-all"></i> 返回
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <th:block th:include="include :: bootstrap-table-fixed-columns-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('biz:wallet:edit')}]];
        var removeFlag = [[${@permission.hasPermi('biz:wallet:remove')}]];
        var statusDatas = [[${@dict.getType('enableStatus')}]];
        var prefix = ctx + "biz/wallet";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                fixedColumns: true,
                fixedRightNumber: 1,
                sortName: "customer_id",
                sortOrder: "desc",
                modalName: "用户钱包",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'customerId',
                    title: '客户ID',
                    visible: false
                },
                {
                    field: 'deposit',
                    title: '押金(元)',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'depositTranNo',
                    title: '押金交易号',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'depositTranTime',
                    title: '押金缴纳时间',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'balance',
                    title: '余额(元)',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push(value);
                        actions.push(" ");
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="recharge(\'' + row.customerId + '\')"><i class="fa fa-plus-circle"></i> 充值</a> ');
                        return actions.join('');
                    }
                },
                {
                    field: 'balanceTranNo',
                    title: '余额交易号',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'remark',
                    title: '备注',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'status',
                    title: '启用状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    field: 'updateTime',
                    title: '更新时间',
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value, 10, 'open');
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a style="margin-top: 3px;" class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="tarnLog(\'' + row.customerId + '\',\'' + row.customerId + '\')"><i class="fa fa-yen"></i> 交易记录</a> ');
                        actions.push('<a style="margin-top: 3px;" class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="detail(\'' + row.customerId + '\')"><i class="fa fa-info"></i> 详情</a> ');
                        // actions.push('<a style="margin-top: 3px;" class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.customerId + '\')"><i class="fa fa-remove"></i> 删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        /**
         * 充值
         **/
        function recharge(id) {
            var url = prefix + '/recharge/' + id + "?time=" + (new Date()).getTime();
            $.modal.open("余额充值", url);
        }
        function detail(id) {
            var url = prefix + '/detail/' + id + "?time=" + (new Date()).getTime();
            $.modal.openTab("用户钱包详情", url);
        }
        /**
         * 钱包交易记录
         * @param id
         */
        function tarnLog(id,name){
            var url = ctx + '/biz/tranlog?tranType=wallet&customerId=' + id;
            $.modal.openTab("交易记录", url);
        }
    </script>
</body>
</html>